package com.jn.service.hollyService;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.jn.util.CommonUtils;

@Component
@Transactional
public class WqtService {
	private static Logger logger = LoggerFactory.getLogger(WqtService.class);
	@Autowired
	private JdbcTemplate jdbcTemplate;

	/**
	 * @Title insertTempLiuxd
	 * @Description 插入temp_liuxd临时表，插入前先清空该表
	 * @param terminalList
	 */
	public void insertTempLiuxd(List<String> terminalList) {
		jdbcTemplate.execute("delete from temp_liuxd");// 清空临时表
		List<String> sqlList = new ArrayList<String>();
		for (int i = 0; i < terminalList.size(); i++) {
			String terminalNo = terminalList.get(i);
			sqlList.add("insert into temp_liuxd values('" + terminalNo + "')");
			if (sqlList.size() >= 100 || (i == terminalList.size() - 1)) {
				jdbcTemplate.batchUpdate((String[]) sqlList
						.toArray(new String[sqlList.size()]));
				sqlList = new ArrayList<String>();
			}
		}
	}
   
}
